<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use App\Scopes\SelltimeScope;

class Testc extends Model
{
    use SoftDeletes;
    protected $table = 'testc';
    protected $guarded = [];
    protected $dates = ['deleted_at'];
    public $timestamps = false;

    protected static function boot()
    {
        parent::boot();
        // static::addGlobalScope('uid', function (Builder $builder) {
        //     $builder->where('uid', '>', 2);
        // });
    }

    /**
     * 添加一个本地作用域
     * @return Builder
     */
    public function scopeBig($query)
    {
        return $query->where('uid', '>', 2);
    }

    public function scopeOfUid($query, $uid)
    {
        return $query->where('uid', $uid);
    }

    public function user()
    {
        return $this->belongsTo('App\Models\User', 'uid');
    }
}
